<?php App::import('Sanitize'); ?>
<div class="breadcrumbs">		
	<?php
	$items = array(
		array('Home', array('controller' => 'users', 'action' => 'updates')),
		array('Inbox', array('controller' => $this->params['controller'], 'action' => $this->params['action']))
	);
	echo $this->Navigation->breadcrumbs($items);
	?>
</div>
<?php echo $this->Session->flash(); ?>
<div class="welcome-inbox">
	<h1>Inbox</h1>
	<div class="button_nieuwbericht">
		<?php echo $this->Html->link(__('Nieuw Bericht', true), array('controller' => 'messages', 'action' => 'send'),array('class'=>'new-mail')); ?>
	</div>
</div>
<div class="content-wrapper ui-corner-all">		
	<div class="block-white-top ui-corner-tl ui-corner-tr">
		<div class="message-list">
			<?php if (count($messages) > 0) : ?>	
				<?php foreach($messages as $message): ?>
					<?php if ($message['Message']['read'] == 0): ?>
						<div onclick="location.href='<?php echo $this->Html->url(array('controller' => 'messages', 'action' => 'view', $message['Message']['id'])); ?>';" style="cursor: pointer;" class="message-detail">
							<div class="message-detail-text">	
								<div class="time"><?php echo $this->FixDate->fix_date($message['Message']['created'], 'time'); ?></div>
								<table>
								<tr><th><h1><?php echo Sanitize::html($message['User']['username']); ?></h1></th></tr>
								<tr><th><h2><?php echo Sanitize::html($message['Message']['subject']); ?></h2></th></tr>
								</table>
								<p><?php echo $this->FixText->fix_text(Sanitize::html($message['Message']['body']), 45, TRUE); ?></p>
							</div>	
						</div>		
					<?php else: ?>
						<div onclick="location.href='<?php echo $this->Html->url(array('controller' => 'messages', 'action' => 'view', $message['Message']['id'])); ?>#<?php echo $message['Message']['id']; ?>'" style="cursor: pointer;" class="message-detail-read">
							<div class="message-detail-text">	
								<div class="time"><?php echo $this->FixDate->fix_date($message['Message']['created'], 'time'); ?></div>
								<table>
								<tr><th><h1><?php echo Sanitize::html($message['User']['username']); ?></h1></th></tr>
								<tr><th><h2><?php echo Sanitize::html($message['Message']['subject']); ?></h2></th></tr>
								</table>
								<p><?php echo $this->FixText->fix_text(Sanitize::html($message['Message']['body']), 45, TRUE); ?></p>
							</div>	
						</div>
					<?php endif; ?>
				<?php endforeach; ?>
			<?php else: ?>
				<div class="message-detail-read">
					<div class="message-detail-text">
						<h2>Sorry, je hebt geen berichten.</h2>
					</div>
				</div>
			<?php endif; ?>					
		</div>
	</div>
	<div class="white-bottom ui-corner-br ui-corner-bl"></div>
</div>
